package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


/**
 * @ClassName SupplierController
 * @Author 波
 * @Date 2024/9/24 10:11
 * 供应商管理
 */
@RestController
@RequestMapping("/supplier")
public class SupplierController {
    @Autowired
    private SupplierService supplierService;

    @PostMapping("/list")
    public Map<String, Object> list(Integer page,Integer rows,String supplierName) {
        Map<String, Object> map = supplierService.list(page,rows,supplierName);
        return map;
    }

    @PostMapping("/save")
    public ServiceVO save(Supplier supplier) {
        supplierService.save(supplier);
        return new ServiceVO<>(SuccessCode.SUCCESS_CODE, SuccessCode.SUCCESS_MESS, null);
    }

    @PostMapping("/delete")
    public ServiceVO delete(@RequestParam(value = "ids") String ids) {
        supplierService.delete(ids);
        return new ServiceVO<>(SuccessCode.SUCCESS_CODE, SuccessCode.SUCCESS_MESS, null);
    }
}
